import { CATEGORY_GET_LIST } from '../mutation-types';
import { getCatagoryList } from '../../api';
// import request from '../../utils/wxRequest';

const state = {
  data: {}
};

const getters = {
  data: (state) => state.data
};

const mutations = {
  [CATEGORY_GET_LIST](state, payload) {
    console.log(payload);
    state.data = payload.data;
  }
};

const actions = {
  [CATEGORY_GET_LIST]({ commit }) {
    console.log('TODO');
    getCatagoryList()
      .then(res => {
        console.log(res);
        commit({
          type: CATEGORY_GET_LIST,
          data: res.data
        });
      })
      .catch(e => {
        console.log(e);
      });
  }
};

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
};
